Apache/Varnish/PHP: Just to confirm, is it possible to automatically update $_SERVER['REMOTE_ADDR'] to have the real client's IP?

Posted by user1284857 on Server Fault See other posts from Server Fault or by user1284857
Published on 2012-09-08T07:07:19Z Indexed on 2012/09/08 9:40 UTC
Read the original article Hit count: 138

Filed under:
|
|

I just cannot seem to get the real client IP to show in PHP's $_SERVER['REMOTE_ADDR']. It shows in $_SERVER['X_FORWARDED_FOR'], but the $_SERVER['REMOTE_ADDR'] always points to the Varnish service IP.

I've played around with just about every Varnish vcl suggestion I could find. I've installed Apache module mod_rpaf. But I still cannot get $_SERVER['REMOTE_ADDR'] to reflect the client's real IP...

So my question is, is this even possible? Does everyone who uses Varnish have to do something like this for all PHP applications?:

$_SERVER['REMOTE_ADDR'] = $_SERVER['X_FORWARDED_FOR'];

Or am I simply not configuring it correctly?

© Server Fault or respective owner

Related posts about apache2

Related posts about php